<template>
	
	<view class="">
		
		<view v-if="props.cur === 2" class="itemList">
			<view class="itemLeft">
				<text class="syLabel">{{item?.businessType?.name}}</text> 
				<text class="syTime">{{item?.createTime}}</text> 
			</view>
			<view class="">
				<text class="syNum">+{{item?.finalAmount}}</text>
			</view>
		</view>
		
		<view v-if="props.cur === 1" class="itemList">
			<view class="itemLeft">
				<text class="syLabel">{{item?.businessType?.name}}</text> 
				<text class="syTime">{{item?.createTime}}</text> 
			</view>
			<view class="">
				<text class="syNum">+{{item?.amount}}</text>
			</view>
		</view>
		
		<view v-else-if="props.cur === 0" class="itemWrap">
			<view class="itemTopWrap">
				<view class="" @click="toliaotian(props.item.userId)">
					<image class="userImg" :src="httpUrl+props.item?.avatarId"></image>
				</view>
				<view class="itemRight">
					<view class="" style="flex:1;">
						<view class="biaoti" @click="toliaotian(props.item.userId)">
							<text class="fName">{{props.item?.userName}}</text>
							<!-- <text class="label">{{props.item?.appUser?.userName}}</text> -->
							<TeamTag :partnerLevel="props.item?.partnerLevel"/>
						</view>
						<text class="time">{{props.item?.createTime}}</text>
					</view>
					<view class="zhiWrap">
						<text size="mini"  @click="guanzhu(props.item.userId,props.item?.followFlag)" type="success">{{props.item?.followFlag === 'N' ? '+ 关注' : '已关注'}}</text>
					</view>
				</view>
			</view>
			
		</view>
		
	</view>
	
</template>

<script setup lang="ts">
	import { ref } from 'vue';
	import NavBar from '@/components/navBar.vue';
	import TeamTag from './teamTag.vue';
	import {saveFollow} from '@/utils/api/userinfo.ts'
	import { defineEmits } from 'vue';
	
	const httpUrl = getApp().globalData.baseUrl+'/app/file/viewFile?fileId='

	const props = defineProps({
			item:{
				type:Object
			},
			cur:{
				type:Number
			}
		})
		
	// 定义触发的事件及其数据类型
	const emit = defineEmits(['downCallback']);
		
	const toliaotian = (userId) =>{
		const conversationID = `C2C${userId}`;
		uni.navigateTo({ url: `/pages/TUIKit/components/TUIChat/index?conversationID=${conversationID}&userId=${userId}` });
	}
	
	const guanzhu = (userId,followFlag) =>{
		saveFollow({data:{userId:userId}}).then(res=>{
			if(res.success){
				uni.showToast({
					title: followFlag === 'Y' ? "取消关注成功" : '关注成功'
				})
				emit('downCallback')
			}else{
				uni.showToast({
					title:res.msg
				})
			}
			
		})
	}
	
</script>

<style lang="scss" scoped>
	.itemWrap{
		border-radius: 24rpx;
		margin-bottom: 24rpx;
		
		.itemTopWrap{
			display: flex;
			align-items: center;
			background: #EFF6FF;
			border-radius: 36rpx 36rpx 36rpx 36rpx;
			padding: 24rpx;
		}
		
		.zhiWrap{
			display: flex;
			justify-content: center;
			align-items: center;
			margin-top: 8rpx;
			width: 120rpx;
			height: 52rpx;
			background: #1188FF;
			border-radius: 26rpx 26rpx 26rpx 26rpx;
			
			text{
				height: 36rpx;
				font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
				font-weight: normal;
				font-size: 26rpx;
				color: #FFFFFF;
				line-height: 35rpx;
				text-align: left;
				font-style: normal;
				text-transform: none;
			}
		}
		
		.userImg{
			width: 96rpx;
			height: 96rpx;
			background: #D9D9D9;
			border-radius: 48rpx 48rpx 48rpx 48rpx;
		}
	}
	
	.itemRight{
		flex:1;
		display: flex;
		align-items: center;
		margin-left: 12rpx;
	}
	
	.biaoti{
		display: flex;
		align-items: center;
		flex:1;
	}
	
	.label{
		font-size: 32rpx;
		color: #000000;
		font-weight: bold;
	}
	
	.status{
		font-size: 24rpx;
		color: #8C8C8C;
	}
	
	.time{
		height: 36rpx;
		font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
		font-weight: normal;
		font-size: 24rpx;
		color: #8C8C8C;
		line-height: 36rpx;
		text-align: left;
		font-style: normal;
		text-transform: none;
	}
	
	
	
	.itemList {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-bottom: 24rpx;
		background-color: #EFF6FF;
		margin-bottom: 0;
		padding: 12rpx 12rpx;
	
		.itemLeft {
			display: flex;
			flex-direction: column;
		}
	
		.syLabel {
			font-family: Alibaba PuHuiTi 2, Alibaba PuHuiTi 20;
			font-weight: normal;
			font-size: 28rpx;
			color: #000;
		}
	
		.syTime {
			font-family: Alibaba PuHuiTi 2, Alibaba PuHuiTi 20;
			font-weight: normal;
			font-size: 24rpx;
			color: #666;
			margin-top: 8rpx;
		}
		.syNum {
			font-family: Alibaba PuHuiTi 2, Alibaba PuHuiTi 20;
			font-weight: normal;
			font-size: 32rpx;
			color:#6AC922
		}
	}
	
	.fName{
		font-family: Alibaba PuHuiTi 2.0, Alibaba PuHuiTi 20;
		font-weight: normal;
		font-size: 28rpx;
		color: #262626;
		line-height: 48rpx;
		text-align: left;
		font-style: normal;
		text-transform: none;
	}
	
</style>